#!/bin/sh
# srcboot2
set -x

# SCA2 1434 channels 3 and 4

############################################ SEGTBL:
BINFILE=segtbl.bin
RAMADDR=0x00001000

# load y command
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00000003
sleep 1

# address
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V $RAMADDR
sleep 1

# transfer data
hwblkio -W -b 3 -B 4 -s 32 -x -@0x0010023c -f $BINFILE
sleep 1

# set bit 3 of ICR, host flag 0 to end transfer
hwblkio -W -b 1 -B 1 -x -@0x00100220 -V 0x00000008
sleep 1

# clear bit 3 of ICR, host flag 0 to start command mode of loader
hwblkio -W -b 1 -B 1 -x -@0x00100220 -V 0x00000000
sleep 1

############################################ MAIN0:
BINFILE=main0.bin
RAMADDR=0x00001000

# load p command
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00000001
sleep 1

# address
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V $RAMADDR
sleep 1

# transfer data
hwblkio -W -b 3 -B 4 -s 32 -x -@0x0010023c -f $BINFILE
sleep 1

# set bit 3 of ICR, host flag 0 to end transfer
hwblkio -W -b 1 -B 1 -x -@0x00100220 -V 0x00000008
sleep 1

# clear bit 3 of ICR, host flag 0 to start command mode of loader
hwblkio -W -b 1 -B 1 -x -@0x00100220 -V 0x00000000
sleep 1

############################################ MAINY0:
BINFILE=mainy0.bin
RAMADDR=0x00001080

# load y command
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00000003
sleep 1

# address
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V $RAMADDR
sleep 1

# transfer data
hwblkio -W -b 3 -B 4 -s 32 -x -@0x0010023c -f $BINFILE

# set bit 3 of ICR, host flag 0 to end transfer
hwblkio -W -b 1 -B 1 -x -@0x00100220 -V 0x00000008
sleep 1

# clear bit 3 of ICR, host flag 0 to start command mode of loader
hwblkio -W -b 1 -B 1 -x -@0x00100220 -V 0x00000000
sleep 1


############################################ MONVECTS
BINFILE=monvects.bin
RAMADDR=0x00000000

# load p command
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00000001
sleep 1

# address
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V $RAMADDR
sleep 1

# transfer data
hwblkio -W -b 3 -B 4 -s 32 -x -@0x0010023c -f $BINFILE

# set bit 3 of ICR, host flag 0 to end transfer
hwblkio -W -b 1 -B 1 -x -@0x00100220 -V 0x00000008
sleep 1

# clear bit 3 of ICR, host flag 0 to start command mode of loader
hwblkio -W -b 1 -B 1 -x -@0x00100220 -V 0x00000000
sleep 1

############################################ start
START=0x00001000
# start p command
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00000004
sleep 1

# address
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V $START
sleep 1
